package com.atcumt.Huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 密码验证合格程序
 * <p>
 * 1.长度超过8位
 * <p>
 * 2.包括大小写字母、数字、其它符号,以上四种至少三种
 * <p>
 * 3.不能有长度大于2的不含公共元素的子串重复（其他符号不含空格或换行）
 */
public class HJ10 {

    public static void main(String[] args) throws IOException {

        // 字符串多行输入，IO 流
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // String s = br.readLine();
        String s;

        while ((s = br.readLine())!=null) {
            if (s.length() <= 8) {
                System.out.println("NG");
                continue;
            }
            int[] count = new int[4];
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
                    count[0] = 1;
                } else if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') {
                    count[1] = 1;
                } else if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {
                    count[2] = 1;
                } else {
                    count[3] = 1;
                }
            }
            if (count[0] + count[1] + count[2] + count[3] < 3) {
                System.out.println("NG");
                continue;
            }
            if (getSubString(s, 0, 3)) {
                System.out.println("NG");
                continue;
            } else {
                System.out.println("OK");
            }
        }
    }

    private static boolean getSubString(String s, int l, int r) {
        if (r >= s.length()) {
            return false;
        }
        if (s.substring(r).contains(s.substring(l, r))) {
            return true;
        } else {
            return getSubString(s, l + 1, r + 1);
        }
    }
}
